package org.hjl.commonutils.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hjl.commonutils.result.R;

/**
 * @author hjl
 * @since 2024-08-05
 */

@Data
@EqualsAndHashCode(callSuper = true)
public class GlobalException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private String msg;
    private int code = R.ERROR_CODE;

    public GlobalException() {
        this.msg = "操作失败";
    }

    public GlobalException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public GlobalException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public GlobalException(int code, String msg) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public GlobalException(int code, String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }

}
